<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    要求监听name的改变  <hr>
    <button @click="setName"> 修改 </button>
    <p> {{ people.name }} </p>
  </div>
</body>
<script src="../../lib/vue.global.js"></script>
<script>
  Vue.createApp({
    data () {
      return {
        people: {
          name: 'laodeng'
        }
      }
    },    watch:{
     people:{
        deep:true,
        immediate:true,
        handler(newName){
            console.log(newName.name);
        }

     }


    },
  methods: {
      setName () {
        this.people.name = 'jack'
      }
    },

  }).mount('#app')
</script>
</html>